﻿using Model3;
using System;
using System.Threading;
using System.Windows.Forms;
using TicketService.Client.Common;

namespace GEMINI_OP10
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            //处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //FormUserLoginInterface UserLogin = new FormUserLoginInterface();
            //DialogResult Result = UserLogin.ShowDialog();
            //if (Result == DialogResult.OK)
            //{
                Application.Run(new FormMain());
            //}
            //else
            //{
            //    Application.Exit();
            //}
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = e.ExceptionObject as Exception;
            Log.WriteLog($"程序发生未处理的异常{ex.Message}\r\n{ex.StackTrace}");
        }

        private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            var ex = e.Exception;
            Log.WriteLog($"程序发生未处理的异常{ex.Message}\r\n{ex.StackTrace}");
        }

        public static UserLogin userlogin = new UserLogin();
    }
}
